<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<p>
		整数1：
		<input type="text" id="num1">
	</p>
	<p>
		整数2：
		<input type="text" id="num2">
	</p>
	<button onclick="change('+')">相加</button>
	<button onclick="change('-')">相减</button>
	<button onclick="change('*')">相乘</button>
	<button onclick="change('/')">相除</button>

	<p>
       结果：
       <input type="text" id="res">
	</p>
    <script>
        function change(e) {
        	var num1 = document.querySelector("#num1").value;
        	var num2 = document.querySelector("#num2").value;
        	num1 = Number(num1);
        	num2 = Number(num2);

        	switch(e){
        		case '+':
      	  	 document.querySelector("#res").value= num1 + num2;
       	  	    break;
       	  	case '-':
       	  	    document.querySelector("#res").value= num1 - num2;
       	  	    break;
       	  	case '*':
       	  	    document.querySelector("#res").value= num1 * num2;
       	  	    break;
       	  	case '/':
       	  	    document.querySelector("#res").value= num1 / num2;
       	  	    break;
        	}
        }
      
    </script>
</body>
</html>